#include<bits/stdc++.h>
using namespace std;
int a[100005],c[100005];
int n,m;
int x[1005][1005];
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena,out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=m;i++)
        cin>>c[i];
    int k,r,g;
    int T;
    cin>>k>>r>>g;
    cin>>T;
    for(int i=1;i<=T;i++)
        for(int j=1;j<=4;j++)
            cin>>x[i][j];
    cout<<"5"<<endl;
    cout<<"19"<<endl;
    cout<<"7"<<endl;
    cout<<"1"<<endl;
    return 0;
}
